<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/21
 * Time: 11:51
 */
namespace app\api\controller;

use app\api\Common;
use app\model\MatchList;
use app\model\MatchLive;
use app\model\PhaseList;
use app\model\SportName;
use think\Request;

class Center extends Common{

    /**
     * 竞猜中心  H5
     */
    public function guess_center(){

        //获取赛事类型
        $match_type = SportName::all();

        //获取体育类型
//        $type_id = Request::instance()->param('type_id');
        //1为足球
//        if($type_id==1){
//
//        }
        //获取未结束的赛程
        $match_list = MatchLive::where('is_end','<>',3)->order('start_time')->paginate(6);

        foreach ($match_list as $k => $v){
            //拼接赛程全名
            $v['matcheName'] = MatchList::where('id',$v['bigMatch_id'])->value('match_name').PhaseList::where('id',$v['phase_id'])->value('phase_name'). $v['matcheName'];
            $match_list[$k]['time'] = date("H:i",$v['start_time']);
            $v['start_time']= date("m月d日",$v['start_time']).weekday($v['start_time']);
            $list[$v['start_time']][] = $v;
            unset($match_list[$k]);
        }
        $re = [];
        foreach($list as $ke=>$va)
        {
            $re[]['time'] = $ke;
            foreach($re as $a=>$v)
            {
                foreach($va as $key=>$value)
                {
                    if($v['time'] == $value['start_time'])
                    {
                        $re[$a]['phase_list'] = $va;
                    }
                }
            }
        }
        $match_list = $re;
        return view('',['match_list'=>$match_list,'match_type'=>$match_type]);
    }
}